const int MOD = 1e9 + 7;
const int MX = 1e5 + 1;

typedef long long LL;
LL f[MX], g[MX];

int init = [](){
    f[0] = g[0] = 1;
    f[1] = g[1] = 1;
    f[2] = g[2] = 2;
    f[3] = g[3] = 4;
    for(int i = 4; i < MX; ++i)
    {
        f[i] = (f[i - 1] + f[i - 2] + f[i - 3]) % MOD;
        g[i] = (g[i - 1] + g[i - 2] + g[i - 3] + g[i - 4]) % MOD;
    }
    return 0;
}();


class Solution {
public:
    int countTexts(string pressedKeys) {
        LL ans = 1;
        int n = pressedKeys.size();
        int count = 0;
        for(int i = 0; i < n; ++i)
        {
            char c = pressedKeys[i];
            ++count;
            if(i == n - 1 || pressedKeys[i + 1] != c)
            {
                ans = ans * (c == '7' || c == '9' ? g[count] : f[count]) % MOD;
                count = 0;
            }
        }
        return ans;
    }
};
